<?php
define('IN_QY',true);
require("include/common.inc.php");

// 海淘首页商品列表
//首页api
$serh=$_GET['sname'];
$reslut = "select count(*) as a from tbl_skill_details where status=0 and concat(title,details) LIKE '%$serh%'";
$query_reslut = mysql_query($reslut);
$row_reslut=mysql_fetch_array($query_reslut);
$count=$row_reslut['a'];
//页面数量
$page_size=5;
//总页数
$page_count = ceil($count/$page_size);

//第几页
$page=$_GET['page'];
if($page==''){
  $page=1;
}
$last=$page-1;//上一页
$next=$page+1;//下一页

if($page>$page_count){

    $arr = 0;
    echo $arr;
    exit;

}

//页面起始条数
$offset=$page_size*($page-1);
$sql = "select * from tbl_skill_details  where status=0 and concat(title,details) LIKE '%$serh%' order by id desc  limit $offset,$page_size";
$query = mysql_query($sql);

class Stu{  
//app首页商品表，字段解释
    public $id;  
    public $img; 
    public $title;  
    public $price; 
    public $details;
    public $city;
    public $tximg;
    public $txfenlei;
    public $txname;	
	
} 
while($row=mysql_fetch_object($query)){   
   	$imgg=$row->pics; 
   	$img=explode(',',$imgg);		
	$rowg=$img['0'];
	$fd=$row->cat_id; 
	
	$sqljname = "SELECT DISTINCT * from tbl_skill_catgroy  where id='".$fd."' ";
    $queryjname=mysql_query($sqljname);
    $rowjname=mysql_fetch_array($queryjname);
	
	$fdd=$row->uid; 
	$sqljnamee = "SELECT DISTINCT * from tbl_user  where id='".$fdd."' ";
    $queryjnamee=mysql_query($sqljnamee);
    $rowjnamee=mysql_fetch_array($queryjnamee);	
	
    $s=new Stu();
    $s->id=$row->id;  
    $s->title=$row->title;  
    $s->price=$row->price;  
    $s->details=$row->details;  
    $s->city=$row->city;  	
	$s->img=$rowg; 
	
    $s->tximg=$rowjnamee['username'];  
    $s->txfenlei=$rowjname['cat_name'];  
    $s->txname=$rowjnamee['shuyu']; 	
	
	$arr[]=$s;
} 
echo json_encode(array('data'=>$arr)); 

//
